package cn.zqh.brand.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @Author: zqh
 * @Date: 2023-03-11-11:35
 * @Description: 声明消费者配置$
 */
@Configuration
//@Primary
public class MyRabbitConfig {

    private static String EXCHANGE_NAME = "ms6";
    private static String QUEUE_NAME = "ms_queue6";

    /**
     * @Author: zqh
     * @Date:
     * @Description: 上面交换机
     */
    @Bean
    public FanoutExchange exchange(){
        return new FanoutExchange(EXCHANGE_NAME,true,false);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 声明队列
     */
    @Bean
    public Queue queue(){
        return new Queue(QUEUE_NAME,true,false,false);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 声明绑定关系
     */
    @Bean
    public Binding queueBinding(Queue queue,FanoutExchange fanoutExchange){
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }

}
